#ifndef __COMPONENT_CRAFTING_TABLE_H__
#define __COMPONENT_CRAFTING_TABLE_H__

#include "ComponentInventoryBase.h"

namespace PocketSurvival
{
    struct CraftingRecipe;
    struct ComponentCraftingTable : public ComponentInventoryBase
    {
        int32_t craftingGridSize;
        int32_t matchedIngredients[9];
        CraftingRecipe *matchedRecipe;
        
        virtual uint32_t getSlotCapacity(uint32_t slotIndex, int32_t cellValue) override;
        virtual void addSlotItems(uint32_t slotIndex, int32_t cellValue, uint32_t count) override;
        virtual uint32_t removeSlotItems(uint32_t slotIndex, uint32_t count) override;
        void updateCraftingResult();

        inline uint32_t remainsSlotIndex();
        inline uint32_t resultSlotIndex();

        virtual void load(const nlohmann::json &jsonData) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();
    };

    inline uint32_t ComponentCraftingTable::remainsSlotIndex()
    {
        return slotsCount() - 1;
    }
    inline uint32_t ComponentCraftingTable::resultSlotIndex()
    {
        return slotsCount() - 2;
    }
    
} // namespace PocketSurvival

#endif
